Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priority fees on EVMs (EIP-1559) #16342

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

Priority fees on EVMs (EIP-1559) #16342

wants to merge 4 commits into from

Conversation

enjojoy
Copy link
Contributor

@enjojoy enjojoy commented Jan 14, 2025

Description

Added priority fee for all EVM chains except BSC and Ethereum classic (not supported)

Bsc has base fee always at 0, so it's needed to adjust the logic for bsc separately.

Refactored Fee component

Connect part of this PR was moved to #17156

Related Issue

Resolve #16438

Screenshots:

Copy link

github-actions bot commented Jan 14, 2025

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 26
  • More info

Learn more about 𝝠 Expo Github Action

@enjojoy enjojoy force-pushed the feat/priority-fees branch 13 times, most recently from 1976ef5 to 51b93d9 Compare January 17, 2025 14:40
@enjojoy enjojoy force-pushed the feat/priority-fees branch 3 times, most recently from 8b615ab to a02ee59 Compare January 22, 2025 16:30
@enjojoy enjojoy force-pushed the feat/priority-fees branch from a02ee59 to bef5516 Compare February 3, 2025 11:00
Copy link

coderabbitai bot commented Feb 3, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@enjojoy enjojoy force-pushed the feat/priority-fees branch 5 times, most recently from 9062eec to 816379a Compare February 3, 2025 16:00
@enjojoy enjojoy force-pushed the feat/priority-fees branch 4 times, most recently from edf2a0c to a0c530d Compare February 20, 2025 11:48
@enjojoy enjojoy changed the title chore(suite): add priority fee network feature Priority fees on EVMs (EIP-1559) Feb 20, 2025
@enjojoy
Copy link
Contributor Author

enjojoy commented Feb 20, 2025

I separated misc levels from bitcoin, can you please check? @marekrjpolak In the future it would make sense to separate Ethereum from misc too, I think. And then Solana when there will be priority fees as well. But for now I think this is sufficient.

Copy link
Contributor

@vytick vytick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few cosmetic nits from me

@@ -187,6 +188,7 @@ const EthereumDetails = ({
networkType,
}: DetailsProps) => {
const hasSettlementLayer = !!getNetwork(symbol).settlementLayer;
const locale = useLocales();

// TODO: this can be probably moved to FeeRate component
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be moved according to the comment? and also getFeeRate in that case

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved

if (network.networkType === 'ethereum') {
// NOTE: ethereum smart fees are not implemented properly in @trezor/connect Issue: https://github.com/trezor/trezor-suite/issues/5340
// create raw call to @trezor/blockchain-link, receive data and create FeeLevel.normal from it
const feeLevels: 'preloaded' | 'smart' = getNetworkFeatures(network.symbol).includes(
Copy link
Contributor

@vytick vytick Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
const feeLevels: 'preloaded' | 'smart' = getNetworkFeatures(network.symbol).includes(
const feeLevels = getNetworkFeatures(network.symbol).includes(

maxFeePerGas: precomposedTransaction.maxFeePerGas ?? undefined,
maxPriorityFeePerGas: precomposedTransaction.maxPriorityFeePerGas ?? undefined,
gasPrice:
!precomposedTransaction.maxFeePerGas && precomposedTransaction.feePerByte
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Imo moving this ternary to separate const before const transaction = prepareEthereumTransaction({ would make it more readable

// validate if token balance is not 0 or lower than amount
if (
availableTokenBalance &&
(availableTokenBalance === '0' || new BigNumber(amount).gt(availableTokenBalance))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if amount < 0 ?

feePerByte: feeLevel.feePerUnit,
feeLimit: feeLevel.feeLimit,
token,
bytes: 0, // TODO: calculate
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to calculate in this PR?

Copy link
Contributor

@PeKne PeKne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through the code and found no major problems. My comments are rather code-style/readability proposals.

Although it is quite a big change, so make sure that QA will test both ETH priority fees and All the other network fees (even in mobile app) thoroughly before merging this 🙏

@@ -17,6 +17,11 @@ export interface FormState {
setMaxOutputId?: number;
selectedFee?: FeeLevel['label'];
feePerUnit: string; // bitcoin/ethereum/ripple custom fee field (satB/gasPrice/drops)
maxPriorityFeePerGas?: string; // ethereum eip1559 only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about moving all these new attributes to eip1559 object? That would make it more readable, especially when this type is shared for all the networks.

So e.g. FormState.maxPriorityFeePerGas would be --> FormState.eip1559.axPriorityFeePerGas etc.

What do you think?

async load(blockchain: Blockchain) {
if (this.coinInfo.type !== 'bitcoin') return this.loadMisc(blockchain);
if (this.coinInfo.type !== 'bitcoin') return undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change the type of coinInfo received in constructor to BitcoinNetworkInfo, then we can remove this check.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, the BitcoinFees/MiscFees separation looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I will actually create a separate PR only for this part, this PR is already too big and it will be safer to merge it in parts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this should be pretty uncontroversial PR.

@enjojoy enjojoy force-pushed the feat/priority-fees branch 13 times, most recently from 3b7cc44 to ecf33d0 Compare February 28, 2025 20:25
@enjojoy enjojoy force-pushed the feat/priority-fees branch from ecf33d0 to aad7d97 Compare March 1, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP1559: handle eip1559 response in connect and suite
5 participants